package com.hspedu.Homework;

import java.io.*;

/**
 * @author DL5O
 * @version 1.0
 */
public class Homework02 {
    public static void main(String[] args) throws IOException {
        String filePath = "d:\\story2.txt";
        //如果该文本文件不是utf8的话是gbk的，就需要先读入字节流然后再转换成字符流
        //BufferedReader br = new BufferedReader(new FileReader(filePath));

        String charset = "utf-8";
        InputStreamReader isr = new InputStreamReader(new FileInputStream(filePath), charset);//指定编码格式
        BufferedReader br = new BufferedReader(isr);
        String line = "";
        int lineNums = 1;

        while ((line = br.readLine()) != null) {
            System.out.print(lineNums + "   ");
            System.out.println(line);
            lineNums++;
        }
        System.out.println("打印完毕...");
        br.close();
    }
}
